<?php
session_start();
ob_start('ob_gzhandler');
include 'config.php';

if(@$_GET['danhmuc']){
	if(@$_GET['detail']){
		$dt = $_GET['detail'];
		$danhmuc = $_GET['danhmuc'];
		$menu_one = $tc->menu_one($danhmuc);
		$row_menu_one = mysql_fetch_array($menu_one);
		switch($row_menu_one['type_id']){
			case 2 : include_once('blocks/articles_detail.php'); ($row_detail['url_hinh']!='') ? $image='http://'.$domain.'/'.url_articles_thumb_image.$row_detail['url_hinh'] : $image=url_default_image; break;
			case 3 : include_once('blocks/product_detail.php'); ($row_detail['url_hinh']!='') ? $image='http://'.$domain.'/'.url_product_thumb_image.$row_detail['url_hinh'] : $image=url_default_image; break;
			case 5 : include_once('blocks/cohoi_nghenghiep.php'); break;
			default : $view_post = 'Không có loại bạn muốn tìm';
		}
		$url = 'http://'.$domain.'/'.$row_menu_one['url'].$row_detail['name_rewrite'].'.html';
		$seo = $tc->seo($domain,$row_detail['name'],$row_detail['description'],$row_detail['metaKeyword'],$image,$url);
		$slogan = '<h5>"Make <font color="#67a421">your Life</font> better"</h5>';
		$slider = $tc->slider_baner($row_menu_one['id'],1);
		if(mysql_num_rows($slider)>0){
			$row_slider = mysql_fetch_array($slider);
			$view_slider = '<img src="'.url_slider_image.$row_slider['url_hinh'].'" alt="'.$row_slider['name'].'" />';
		}
	}else{
		$dm = $_GET['danhmuc'];
		$dm = explode('/',$dm);
		$danhmuc = $dm[0];
		if($dm[1]=='') $page = 1;
		else{
			$page = $dm[1];
			$trang = ' - Trang '.$page;
		}
		$menu_one = $tc->menu_one($danhmuc);
		$row_menu_one = mysql_fetch_array($menu_one);
		($row_menu_one['url_hinh']=='') ? $image=url_default_image : $image=url_danhmuc_image.$row_menu_one['url_hinh'];
		$url = 'http://'.$domain.'/'.$row_menu_one['url'];
		$seo = $tc->seo($domain,$row_menu_one['title'].$trang,$row_menu_one['metaDescription'].$trang,$row_menu_one['metaKeyword'],$image,$url);
		$slogan = '<h5>"Make <font color="#67a421">your Life</font> better"</h5>';
		$slider = $tc->slider_baner($row_menu_one['id'],1);
		if(mysql_num_rows($slider)>0){
			$row_slider = mysql_fetch_array($slider);
			$view_slider = '<img src="'.url_slider_image.$row_slider['url_hinh'].'" alt="'.$row_slider['name'].'" />';
		}
		switch($row_menu_one['type_id']){
			case 2 : include_once('blocks/articles_list.php'); break;
			case 3 : include_once('blocks/product.php'); break;
			case 4 : include_once('blocks/about.php'); break;
			case 5 : include_once('blocks/cohoi_nghenghiep.php'); break;
			case 6 : include_once('blocks/hinhanh.php'); break;
			case 7 : include_once('blocks/contact.php'); break;
			default : $view_post = 'Không có loại bạn muốn tìm';
		}
	}
	include_once('blocks/header.php');
	include_once('blocks/menu.php');
    include_once('blocks/footer.php');
	$view_post = '<div id="container"><div id="wrapper">'.$view_header.$view_menu.'<div id="slider"><div id="shadow"></div>'.$view_slider.'</div>
	<div id="content">'.$view_post.'</div>'.$view_footer.'</div></div>';
}else{
	$menu_one = $tc->menu_one('trang-chu');
	$row_menu_one = mysql_fetch_array($menu_one);
	($row_menu_one['url_hinh']=='') ? $image=url_default_image : $image=url_danhmuc_image.$row_menu_one['url_hinh'];
	$url = 'http://'.$domain.'/'.$row_menu_one['url'];
	$seo = $tc->seo($domain,$row_menu_one['title'],$row_menu_one['metaDescription'],$row_menu_one['metaKeyword'],$image,$url);
	include_once('blocks/home.php');
}?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<?php echo $seo; ?>
<link href="style.css" rel="stylesheet" type="text/css" />
<link href="assets/wt-rotator.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="library/jquery.js"></script>
<script type="text/javascript" src="website.js"></script>
</head>
<body>
<?php echo $view_post; ?>
<script>
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

  ga('create', 'UA-43817164-3', 'totalife.com.vn');
  ga('send', 'pageview');
</script>
</body>
</html>